Add some reftests related to textview tags
authorMatthias Clasen <mclasen@redhat.com>
Thu, 12 Mar 2015 01:45:48 +0000 (21:45 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 12 Mar 2015 02:04:29 +0000 (22:04 -0400)
This test shows that a) tags override the text view style and
b) tags override each other in the expected way.

testsuite/reftests/Makefile.am
testsuite/reftests/textview-tags.c [new file with mode: 0644]
testsuite/reftests/textview-tags.css [new file with mode: 0644]
testsuite/reftests/textview-tags.ref.ui [new file with mode: 0644]
testsuite/reftests/textview-tags.ui [new file with mode: 0644]

index 607a4f139ca6d1a126063f4923a8dbc962fc97df..d8b8010063a9a894904588d85645bb22844aa1cf 100644 (file)
@@ -418,6 +418,8 @@ testdata = \
        textview-margins.css \
        textview-margins.ref.ui \
        textview-margins.ui \
+       textview-tags.ref.ui \
+       textview-tags.ui \
        toplevel-vs-popup.ref.ui \
        toplevel-vs-popup.ui \
        treeview-crash-too-wide.ref.ui \
@@ -493,6 +495,7 @@ libreftest_la_SOURCES =                     \
        set-default-direction.c         \
        statusbar-remove-all.c          \
        textview-border-windows.c       \
+       textview-tags.c                 \
        $(NULL)
 
 -include $(top_srcdir)/git.mk
diff --git a/testsuite/reftests/textview-tags.c b/testsuite/reftests/textview-tags.c
new file mode 100644 (file)
index 0000000..5a49023
--- /dev/null
@@ -0,0 +1,57 @@
+
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+
+G_MODULE_EXPORT void
+apply_tags_blue (GtkTextView *text_view)
+{
+  GtkTextBuffer *buffer;
+  GtkTextIter start, end;
+  GtkTextIter four, eight;
+
+  buffer = gtk_text_view_get_buffer (text_view);
+  gtk_text_buffer_get_bounds (buffer, &start, &end);
+  gtk_text_buffer_apply_tag_by_name (buffer, "blue", &start, &end);
+  four = start;
+  eight = start;
+  gtk_text_iter_forward_chars (&four, 4);
+  gtk_text_iter_forward_chars (&eight, 8);
+  gtk_text_buffer_apply_tag_by_name (buffer, "black", &four, &end);
+  gtk_text_buffer_apply_tag_by_name (buffer, "white", &eight, &end);
+}
+
+G_MODULE_EXPORT void
+apply_tags_red_blue (GtkTextView *text_view)
+{
+  GtkTextBuffer *buffer;
+  GtkTextIter start, end;
+  GtkTextIter four, eight;
+
+  buffer = gtk_text_view_get_buffer (text_view);
+  gtk_text_buffer_get_bounds (buffer, &start, &end);
+  gtk_text_buffer_apply_tag_by_name (buffer, "red", &start, &end);
+  gtk_text_buffer_apply_tag_by_name (buffer, "blue", &start, &end);
+  four = start;
+  eight = start;
+  gtk_text_iter_forward_chars (&four, 4);
+  gtk_text_iter_forward_chars (&eight, 8);
+  gtk_text_buffer_apply_tag_by_name (buffer, "black", &four, &eight);
+  gtk_text_buffer_apply_tag_by_name (buffer, "white", &eight, &end);
+}
diff --git a/testsuite/reftests/textview-tags.css b/testsuite/reftests/textview-tags.css
new file mode 100644 (file)
index 0000000..899bbeb
--- /dev/null
@@ -0,0 +1,6 @@
+@import "reset-to-defaults.css";
+
+GtkTextView {
+  color: yellow;
+  background-color: yellow;
+}
diff --git a/testsuite/reftests/textview-tags.ref.ui b/testsuite/reftests/textview-tags.ref.ui
new file mode 100644 (file)
index 0000000..8b9fede
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.1 -->
+<interface>
+  <object class="GtkTextTagTable" id="texttagtable1">
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">red</property>
+        <property name="foreground">red</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">blue</property>
+        <property name="foreground">blue</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">black</property>
+        <property name="foreground">black</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">white</property>
+        <property name="foreground">white</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+  </object>
+  <object class="GtkTextBuffer" id="textbuffer1">
+    <property name="tag_table">texttagtable1</property>
+    <property name="text" translatable="yes">red or blue or what</property>
+  </object>
+  <object class="GtkWindow" id="window1">
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkTextView" id="textview1">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="buffer">textbuffer1</property>
+        <signal name="map" handler="reftest:apply_tags_red_blue" swapped="no"/>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/testsuite/reftests/textview-tags.ui b/testsuite/reftests/textview-tags.ui
new file mode 100644 (file)
index 0000000..c04ebf0
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.1 -->
+<interface>
+  <object class="GtkTextTagTable" id="texttagtable1">
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">red</property>
+        <property name="foreground">red</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">blue</property>
+        <property name="foreground">blue</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">black</property>
+        <property name="foreground">black</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">white</property>
+        <property name="foreground">white</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+  </object>
+  <object class="GtkTextBuffer" id="textbuffer1">
+    <property name="tag_table">texttagtable1</property>
+    <property name="text" translatable="yes">red or blue or what</property>
+  </object>
+  <object class="GtkWindow" id="window1">
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkTextView" id="textview1">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="buffer">textbuffer1</property>
+        <signal name="map" handler="reftest:apply_tags_blue" swapped="no"/>
+      </object>
+    </child>
+  </object>
+</interface>